﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Security;
using Infrastructure.Repositories;
using Model.Repositories;
using Model.Service;
using Model.Repositories.Interfaces;
using System.Web.Mvc;

namespace Infrastructure.Service
{
    public class CustomRoleProvider : RoleProvider, ICustomRoleProvider 
    {
        //private IUserCrud _dbUsers = new UserRealization();

        private IUserCrud _dbUsers;
        public CustomRoleProvider(IUserCrud _dbUsers)
        {
            this._dbUsers = _dbUsers;
        }

        public CustomRoleProvider()
        {
            //this._dbUsers = new UserRealization();
            this._dbUsers = DependencyResolver.Current.GetService<IUserCrud>();
        }

        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override string ApplicationName
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override void CreateRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            throw new NotImplementedException();
        }

        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            throw new NotImplementedException();
        }

        public override string[] GetAllRoles()
        {
            throw new NotImplementedException();
        }

        public override string[] GetRolesForUser(string username)
        {
            //_dbUsers = new UserRealization();
            var role = _dbUsers.GetRoleOfUser(username);
            string[] roles = new string[] { role };
            return roles;
        }

        public string GetRoleOfUser(string username)
        {
            //_dbUsers = new UserRealization();
            var role = _dbUsers.GetRoleOfUser(username);
            return role;
        }

        public override string[] GetUsersInRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool IsUserInRole(string username, string roleName)
        {
            throw new NotImplementedException();
        }

        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override bool RoleExists(string roleName)
        {
            throw new NotImplementedException();
        }
    }
}
